import request from "../utils/request";

// 文章列表
// export function article() {
//     return request({
//         url: "/profile",
//         method: "get"
//     });
// }
// https://console-docs.apipost.cn/preview/afbcb3803c676d3a/d64cf9bb9bcd627d?target_id=73143788-e3fa-456d-8946-0fc50c218953


// 登录
export function login(data: any) {
    return request({
        url: "/user/login",
        method: "POST",
        data: data
    });
}
// 手机号登录
export function mobilelogin(data: any) {
    const config = {
        headers: {
            // 'Content-Type': 'multipart/form-data'
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    };
    return request({
        url: "/user/mobilelogin",
        method: "POST",
        data: data,
        ...config
    });
}
// 发送短信
export function smSend(data: any) {
    // 创建配置对象，包含设置Content-Type的头部
    const config = {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    };
    return request({
        url: "/sms/send",
        method: "POST",
        data: data,
        ...config
    });
}
// 注册
export function regist(data: any) {
    const config = {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    };
    return request({
        url: "/user/register",
        method: "POST",
        data: data,
        ...config
    });
}
// 商品列表（首页/分类）
// Productlists/listsByField?page_size=10&field=is_recom&category_id=2
export function productlists(query: any) {
    // const { page_size, field, category_id } = query
    return request({
        url: `/Productlists/listsByField`,
        method: "GET",
        params: query
    });
}
// 商品列表（首页/分类）
// Productlists/listsByField?page_size=10&field=is_recom&category_id=2
export function getSlides() {
    // const { page_size, field, category_id } = query
    return request({
        url: `/index/getSlides`,
        method: "GET"
    });
}
// 公告
export function getDynamics() {
    // const { page_size, field, category_id } = query
    return request({
        url: `/index/getDynamics`,
        method: "GET"
    });
}
// 商品详情
export function productInfo(id: number) {
    // const { page_size, field, category_id } = query
    return request({
        url: `Productlists/read?id=${id}`,
        method: "GET"
    });
}
// 商品分类
export function getCates() {
    // const { page_size, field, category_id } = query
    return request({
        url: `index/cates`,
        method: "GET"
    });
}

// 我的
// 个人信息
export function userInfo(data?: any) {
    const config = {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    };
    return request({
        url: `user/index`,
        method: "POST",
        data,
        ...config
    });
}
// 修改信息
export function userProfile(data?: any) {
    return request({
        url: `user/profile`,
        method: "POST",
        data
    });
}
// 我的团队
export function myTeam(data?: any) {
    const config = {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    };
    return request({
        url: `user/myTeam`,
        method: "POST",
        data,
        ...config
    });
}


// 商城
// 商品结算
export function preOrder(data?: any) {
    return request({
        url: `Productlisto/preOrder`,
        method: "POST",
        data,
    });
}
// 商品sku
export function productSku(id: number, attrs: string, data?: any) {
    return request({
        url: `Productlists/sku?product_id=${id}&attrs=${attrs}`,
        method: "post",
        data
    });
}
// 提交订单
export function createorder(data: any) {
    return request({
        url: `Productorder/createorder`,
        method: "post",
        data
    });
}
// 获取商品清单
export function getOrder(data: any) {
    return request({
        url: `Productlisto/getOrder`,
        method: "post",
        data
    });
}
// 店铺信息
export function getStoreInfo() {
    return request({
        url: `index/getStoreInfo`,
        method: "get",
    });
}
// 加入购物车
export function ProductcartCreate(data: any) {
    return request({
        url: `Productcart/create`,
        method: "post",
        data
    });
}
// 购物车列表
export function ProductcartLists(data: any) {
    return request({
        url: `Productcart/lists`,
        method: "post",
        data
    });
}
// 删除商品
export function ProductcartDel(data: any) {
    return request({
        url: `Productcart/del`,
        method: "post",
        data
    });
}




// 我的
// 订单列表
export function ProductorderLists(data: any) {
    return request({
        url: `Productorder/lists`,
        method: "post",
        data
    });
}
// 确认订单
export function confirmOrder(data: any) {
    return request({
        url: `Productorder/confirmOrder`,
        method: "post",
        data
    });
}
// // 省市区
// export function getAreaList() {
//     return request({
//         url: `District/lists`,
//         method: "get", 
//     });
// }
// 省市区
export function getAreaList() {
    return request({
        url: `district/lists1`,
        method: "get",
    });
}
// 添加/编辑/默认地址
export function handleAddress(data: any) {
    return request({
        url: `Transport/address`,
        method: "post",
        data
    });
}
// 地址列表
export function getAddress(data: any) {
    return request({
        url: `Transport/index`,
        method: "post",
        data
    });
}
// 提现申请
export function WithdrawCreate(data: any) {
    return request({
        url: `Withdraw/create`,
        method: "post",
        data
    });
}
// 提现类型
export function WithdrawWdInfo(data: any) {
    return request({
        url: `Withdraw/wdInfo`,
        method: "post",
        data
    });
}
// 上传图片
export function commonUpload(data: any) {
    return request({
        url: `common/upload`,
        method: "post",
        data
    });
}
// 编辑微信收款信息
export function changeWechat(data: any) {
    return request({
        url: `user/changeWechat`,
        method: "post",
        data
    });
}
// 编辑支付宝收款信息
export function changeAlipay(data: any) {
    return request({
        url: `user/changeAlipay`,
        method: "post",
        data
    });
}
// 编辑支付宝收款信息
export function fetchSuggest(data: any) {
    return request({
        url: `user/suggest`,
        method: "post",
        data
    });
}

// 流水明细
// export function flowing(data: any) {
//     return request({
//         url: `User/moneyChanges`,
//         method: "post",
//         data
//     });
// }

export const flowing = (data: any): any => {
    return request({
        url: `User/moneyChanges`,
        method: "post",
        data
    });
}

// 添加银行卡
export function addBankCard(data: any) {
    return request({
        url: `Banks/create`,
        method: "post",
        data
    });
}

//  银行卡列表
export function getBankCard(data: any) {
    return request({
        url: `Banks/index`,
        method: 'POST',
        data
    })
}

//  默认银行卡
export function changeDefault(data: any) {
    return request({
        url: `Banks/edit`,
        method: 'POST',
        data
    })
}

//  删除银行卡
export function deleteBank(data: any) {
    return request({
        url: `Banks/delete`,
        method: 'POST',
        data
    })
}

// 充值支付
export function reCharge(data: any) {
    return request({
        url: `Recharge/create`,
        method: "post",
        data
    });
}
// 提现记录
export function WithdrawList(data: any) {
    return request({
        url:`Withdraw/lists`,
        method: "post",
        data
    });
}

//  会员签到
export function getSigning(data: any) {
    return request({
        url: `User/signing`,
        method: "post",
        data
    });
}
